package com.nf.action;

import com.nf.service.TestService;
import com.nf.service.TestServiceIml;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/testServlet")
public class TestServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String currentPageStr = request.getParameter("currentPage");
        int currentPage = 1;
        if (currentPageStr!=null){
            currentPage = Integer.parseInt(currentPageStr);
        }
        System.out.println( "取第几页："+ currentPage);

        TestService testService = new TestServiceIml();

        System.out.println(testService.getSelectPageCourse(currentPage));
        request.setAttribute("currentPage",currentPage);
        request.setAttribute("countRow",testService.getCountRow());
        request.setAttribute("pageSize",testService.getPageSize());
        request.setAttribute("courseList",testService.getSelectPageCourse(currentPage));
        request.getRequestDispatcher("show.jsp").forward(request,response);
    }
}
